package com.example.demo2.service;

import com.example.demo2.bean.AdminBean;
import com.example.demo2.dao.AdminBeanDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Example;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class AdminBeanService {

    @Autowired
    AdminBeanDao dao;
    public AdminBean login(AdminBean adminBean) {
        AdminBean adminBean1 = dao.findOne(Example.of(adminBean)).orElse(null);
        return adminBean1;
    }

    public AdminBean register(AdminBean adminBean) {
        AdminBean save = dao.save(adminBean);
        return save;
    }

    public AdminBean findone(AdminBean adminBean) {
        AdminBean adminBean1 = dao.findOne(Example.of(adminBean)).orElse(null);
        return adminBean1;
    }

    public List<AdminBean> list() {
        List<AdminBean> all = dao.findAll();
        return all;
    }

    public void deleteById(Integer admin_id) {
        dao.deleteById(admin_id);
    }

    public AdminBean update(AdminBean adminBean) {
        AdminBean save = dao.save(adminBean);
        return save;
    }

    public AdminBean addone(AdminBean adminBean) {
        AdminBean save = dao.save(adminBean);
        return save;
    }

}
